package com.hmall.order.web;

import com.hmall.order.dto.OrderDTO;
import com.hmall.order.pojo.Order;
import com.hmall.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order")
public class OrderController {

   @Autowired
   private IOrderService orderService;

   /**
    * 根据id查询订单
    * @param orderId
    * @return
    */
   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      return orderService.getById(orderId);
   }

   /**
    * 用户下单
    * @param orderDTO
    * @return
    */
   @PostMapping
   public String creatOrder(@RequestBody OrderDTO orderDTO){
      return orderService.creatOrder(orderDTO);
   }
}
